package com.onlyMe.base
{
	import com.flesler.componentas.core.Component;
	import com.flesler.componentas.core.Entity;
	import com.flesler.componentas.core.base.BaseComponent;
	import com.qb9.flashlib.utils.ClassUtil;
	
	public class BasicComponent extends BaseComponent
	{
		private var prefix:String;
		private var logs:LoggerWrapper;
		
		public function BasicComponent()
		{
		}
		
		protected function createLogger(prefix:String):void
		{
			this.prefix = prefix;
			logs = new LoggerWrapper(prefix);
		}
		
		// Logging
		
		protected final function debug(...args:Array):void { logs.debug(args); }
		protected final function info(...args:Array):void { logs.info(args); }
		protected final function warning(...args:Array):void { logs.warning(args); }
		protected final function error(...args:Array):void { logs.error(args); }
		
		// Components
		
		protected function require(type:Class):Component
		{
			var component:Component = entity.getByType(type);
			if (component)
				return component;
			
			error('Component', type, ' is required');
			return null;
		}
	}
}